﻿using HaiFengShop.Entity;
using HaiFengShop.ORM;
using HaiFengShop.Tools;
using HaiFengShop.Tools.Utils;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using HaiFengShop.ORM.Models;

namespace HaiFengShop.Service
{
    public class GoodsService : BaseServer<tb_goods>
    {
        private readonly ResponseMessage res;
        private readonly GenericJwtToken genericJwtToken;
        public GoodsService(ResponseMessage responseMessage,
            GenericJwtToken genericJwtToken,
             SugarDbContext sugarDbContext) : base(sugarDbContext.Db)
        {
            this.res = responseMessage;
            this.genericJwtToken = genericJwtToken;
        }
        public ResponseMessage GetGoodsCount()
        {
            int count = Context.Queryable<tb_goods>()
                  .Where(s => s.is_delete == 0 && s.is_on_sale == 1)
                  .Count();
            dynamic dcount = new { goodsCount = count };
            res.data = dcount;
            return res;
        }
    }
}
